package com.cjy.controller;


import com.alibaba.nacos.api.model.v2.Result;
import com.cjy.domain.Goods;
import com.cjy.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cjy
 * @since 2024-08-24
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private IGoodsService service;
    @GetMapping("findgoods")
    public Result findgoods(){
        List<Goods> list = service.list();
        return Result.success(list);
    }
    @PostMapping("add")
    public void add(@RequestBody Goods goods){
        service.save(goods);
    }
    @PostMapping("upd")
    public void upd(@RequestBody Goods goods){
        service.updateById(goods);
    }
    @PostMapping("del/{gid}")
    public void del(@PathVariable("gid") Integer gid){
        service.removeById(gid);
    }


}
